#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

int main()
{
    pid_t id = fork();
    if (id < 0)
    {
        return 1;
    }
    else if (id ==0)
    {
        // 子进程
        while (1)
        {
            printf("i am child\n");
            sleep(1);
        }
    }
    else
    {
        // 父进程
        int cut = 5;
        while (cut--)
        {
            printf("i am father:%d\n", cut);
            sleep(1);
        }
        printf("father dead\n");
        exit(2);
    }
    return 0;
}

